package test.zhuwei
{
	import _Pan3D.base.Focus3D;
	import _Pan3D.core.MathCore;
	import _Pan3D.display3D.Display3DContainer;
	import _Pan3D.display3D.interfaces.IDisplay3DContainer;
	
	import _me.Scene_data;
	
	import com.adobe.utils.PerspectiveMatrix3D;
	
	import flash.display.BitmapData;
	import flash.display3D.Context3D;
	import flash.display3D.Context3DBlendFactor;
	import flash.display3D.Context3DProgramType;
	
	public class BuildDisplay3DContainer extends Display3DContainer implements IDisplay3DContainer
	{
		public var isScanning:Boolean=false;
		public var shadowBitmapData:BitmapData=new BitmapData(1024,1024,true)
		private var context3D:Context3D;
		public function BuildDisplay3DContainer()
		{
			super();
		}
		public function scaningShadow(tempContext3D:Context3D):BitmapData
		{
			context3D=tempContext3D;
			
			context3D.clear(0, 0, 0, 0);  //先设置为白色的，这里要和显示阴影的着色器里相加时
			var projMatrix:PerspectiveMatrix3D = new PerspectiveMatrix3D();
			context3D.configureBackBuffer(1024, 1024, 1, true);
			projMatrix.perspectiveFieldOfViewLH(0.928, 1, 0.1, 90000);
			context3D.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, projMatrix, true);
			context3D.setBlendFactors(Context3DBlendFactor.ONE,Context3DBlendFactor.ZERO);
			
			context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 2, Vector.<Number>([0.5, 0.5, 0.5, 1]));
			
			for(var i:int;i<_childrenList.length;i++){
				_childrenList[i].updataAndScanning();
			}
			context3D.drawToBitmapData(shadowBitmapData);

			return shadowBitmapData;
			
		}
		override public function update():void
		{

			for(var i:int;i<_childrenList.length;i++){
				_childrenList[i].update();
			}
		}
	}
}